# 76. 单行道汽车通行时间
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let lines = [];
rl.on('line', function(line) {
lines.push(line);
});
rl.on('close', () => {
const [M, N] = lines[0].split(' ').map(Number);
const speeds = lines.slice(1, M + 1).map(Number);
const time = new Array(M);
time[0] = N/speeds[0];
for(let i=1; i<M; i++) {
let n = N/speeds[i] + i;
time[i] = Math.max(n, time[i-1]);
}
// -M+1 车辆从0开始计数,时间从1开始计数的。没搞懂?
console.log(time[M - 1] - M + 1)
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23